<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Vue 指令 v-model</title>
</head>

<body>
    <div id="descr">
        <p>
            可以用 v-model 指令在表单 input、textarea 及 select 元素上创建双向数据绑定。
        </p>
    </div>
    <div id="app">
        <h1>文本</h1>
        <input v-model="message" placeholder="edit me">
        <p>Message is: {{ message }}</p>

        <h1>多行文本</h1>
        <textarea v-model="message2" placeholder="add multiple lines"></textarea>
        </br>
        <span>Multiline message is:</span>
        <p>{{ message2 }}</p>

        <h1>单个复选框</h1>
        <input type="checkbox" id="checkbox" v-model="checked">
        <label for="checkbox">{{ checked }}</label>

        <h1>复选框组</h1>
        <div id='example-3'>
            <input type="checkbox" id="jack" value="Jack" v-model="checkedNames">
            <label for="jack">Jack</label>
            <input type="checkbox" id="john" value="John" v-model="checkedNames">
            <label for="john">John</label>
            <input type="checkbox" id="mike" value="Mike" v-model="checkedNames">
            <label for="mike">Mike</label>
            <br>
            <span>Checked names: {{ checkedNames }}</span>
        </div>

        <h1>单选按钮</h1>
        <div id="example-4">
            <input type="radio" id="one" value="One" v-model="picked">
            <label for="one">One</label>
            <br>
            <input type="radio" id="two" value="Two" v-model="picked">
            <label for="two">Two</label>
            <br>
            <span>Picked: {{ picked }}</span>
        </div>

        <h1>单选框</h1>
        <div id="example-5">
            <select v-model="selected">
                <option disabled value="">请选择</option>
                <option>A</option>
                <option>B</option>
                <option>C</option>
            </select>
            </br>
            <span>Selected: {{ selected }}</span>
        </div>

        <h1>多选框</h1>
        <div id="example-6">
            <select v-model="selected2" multiple style="width: 50px;">
                <option>A</option>
                <option>B</option>
                <option>C</option>
            </select>
            <br>
            <span>Selected: {{ selected2 }}</span>
        </div>

        <p style="color:red">注意：</p>
        <p style="color:red">1. v-on 可以简写为 @ </p>
        <p style="color:red">2. v-on 可以结合事件修饰符一起使用。</p>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                message: '',
                message2: '',
                checked: false,
                checkedNames: [],
                picked: false,
                selected: '',
                selected2: [],


            },
            methods: {}
        })
    </script>
</body>

</html>